package pro.shushi.pamirs.hr.core.action.eam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.hr.api.enums.eam.EamModelSrcEnum;
import pro.shushi.pamirs.hr.api.enums.eam.UkDevStatEnum;
import pro.shushi.pamirs.hr.api.model.eam.BsMtoolMd;
import pro.shushi.pamirs.hr.api.model.eam.EamMtoolMtPj;
import pro.shushi.pamirs.hr.api.model.eam.EamUkDt;
import pro.shushi.pamirs.hr.api.pmodel.eam.EamUkDtMtoolProxy;
import pro.shushi.pamirs.hr.api.service.eam.EamUkHdMtoolService;
import pro.shushi.pamirs.hr.api.tmodel.EamUkHdMtoolReq;
import pro.shushi.pamirs.meta.annotation.Action;
import pro.shushi.pamirs.meta.annotation.Function;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.annotation.fun.extern.Slf4j;
import pro.shushi.pamirs.meta.enmu.ActionContextTypeEnum;
import pro.shushi.pamirs.meta.enmu.FunctionOpenEnum;
import pro.shushi.pamirs.meta.enmu.FunctionTypeEnum;
import pro.shushi.pamirs.meta.enmu.ViewTypeEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * 保养项目自定义
 */
@Slf4j
@Component
@Model.model(EamUkDtMtoolProxy.MODEL_MODEL)
public class EamUkDtMtoolProxyAction {

    @Function(openLevel = FunctionOpenEnum.API, summary = "选择项目联动")
    @Function.Advanced(displayName = "选择项目联动", type = FunctionTypeEnum.QUERY)
    public EamUkDtMtoolProxy constructPjCodeChange(EamUkDtMtoolProxy data) {
        if (data.getEamMtoolMtPj()==null) {
            return data;
        }
        String orgCode = data.getOrgCode();
        String mmdCode = data.getMmdCode();

        EamMtoolMtPj mtPjRow = new EamMtoolMtPj().setOrgCode(orgCode).setMmdCode(mmdCode)
                .setUkCycType(data.getUkCycType()).queryOne();
        if(mtPjRow != null){
            data.setPjCode(mtPjRow.getPjCode());
            data.setPjName(mtPjRow.getPjName());
            data.setPjType(mtPjRow.getMtoolPjType());
            data.setUkMtd(mtPjRow.getUkMtd());
            data.setUkStd(mtPjRow.getUkStd());
        }

        return data;
    }


}
